layui.use('element', function () {
    var element = layui.element;
});
var binVm = new Vue();
Vue.component('union-header', {
    template: `<div class="layui-header">
        <div class="layui-logo">{{header.logo}}</div>
        <ul class="layui-nav layui-layout-right">
            <li class="layui-nav-item">
                <a href="javascript:;">
                    <img :src="header.userImg" class="layui-nav-img">
                    {{header.userName}}
                </a>
            </li>
            <li class="layui-nav-item"><a href="">退了</a></li>
        </ul>
    </div>`,
    props: {
        'header': {
            type: Object
        }
    }
})

Vue.component('uniocn-side', {
    template: `<div class="layui-side layui-bg-black">
            <div class="layui-side-scroll">
                <!-- 左侧导航区域（可配合layui已有的垂直导航） -->
                <ul class="layui-nav layui-nav-tree" lay-filter="test">
                    <li class="layui-nav-item" v-for="item in side">
                        <a @click="survey($event,item.sidebar)" href="javascript:;">{{item.sidebar}}</a>
                        <dl class="layui-nav-child" v-if="item.sidebarArr.length>0">
                            <dd v-for="l in item.sidebarArr">
                            <a @click="sideHref(l.href)" href="javascript:;">{{l.list}}</a>
                            </dd>
                        </dl>
                    </li>
                </ul>
            </div>
        </div> `,
    props: {
        'side': {
            type: Array
        }
    },
    methods: {
        sideHref: function (href) {
            console.log(href)
            binVm.$emit('goHref', href)
        },
        survey: function ($event, text) {
            if (text == $event.target.innerHTML) {
                window.location.href = 'home.html'
            }
        }
    }
})

Vue.component('uniocn-com', {
    template: ` <div class="layui-body" style='bottom: 0'>
                    <div class="finance-com" >
                        <iframe :src="curHref" frameborder="0" style='width: 100%;height: calc(100vh - 70px)'></iframe>
                    </div>
                </div>`,
    data: function () {
        return {
            curHref: "survey.html",
        }
    },
    mounted: function () {
        binVm.$on('goHref', function (href) {
            this.curHref = href
        }.bind(this));
    }
})
